<template>
  <div>
    <tops> <slot>严选专栏</slot> </tops>

    <ul>
      <li v-for="item in movie" :key="item.id" @click="gotodetail(item)">
        <img :src="item.pic" alt="" />
        <div>
          <p>{{ item.title }}</p>
          <p>{{ item.descript }}</p>
          <button>查看详情</button>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import tops from "@/components/Top";
export default {
  components: {
    tops,
  },
  data() {
    return {
      movie: [],
    };
  },
  mounted() {
    this.$http("https://api.it120.cc/small4/cms/news/list", "get").then(
      (res) => {
        console.log(res);
        this.movie = res.data.data;
      }
    );
  },
  methods: {
    gotodetail(item) {
      this.$router.push({ path: "/choiceness-detail", query: { item } });
    },
  },
};
</script>

<style lang="scss" scoped>
ul {
  width: 100%;
  padding: 0 0.12rem;
  box-sizing: border-box;
  li {
    position: relative;
    text-align: center;
    img {
      width: 100%;
      height: 3.69rem; //184.61
      margin-top: 0.12rem;
    }
    //
    > div {
      position: absolute;
      top: 50%;
      left: 50%;
      color: #fff;
      width: 6rem; //300
      height: 2.032rem; //101.6
      transform: translate(-50%, -50%);
      //超出文字变成...
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      //
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      button {
        font-size: 0.258rem; //12.9
        border: 0.01rem solid #fff;
        border-radius: 999px;
        background-color: rgba(255, 255, 255, 0);
        // padding: 0.15rem 0.3rem;
        width: 1.586rem; //79.3
        height: 0.5766rem; //28.83
        display: inline-block;
        margin: auto;
      }
    }
  }
  li p:nth-of-type(1) {
    font-size: 0.375rem; //18.75
    text-align: center;
  }
  li p:nth-of-type(2) {
    font-size: 0.288rem; //14.4
  }
}
</style>
